//获取应用实例
const app = getApp()

Page({
  data: {
    longitude: "",
    latitude: "",
    controls: [{
      id: 1,
      iconPath: '/resources/location.png',
      position: {
        left: (app.globalData.windowWidth / 2) - 16,
        top: ((app.globalData.windowHeight - 40) / 2) - 32,
        width: 32,
        height: 32
      },
      clickable: true
    }]
  },

  onShow() {
    this.getLocation();
  },

  getLocation() {
    wx.getLocation({
      type: 'gcj02',
      success: this.handleGetLocationSucc.bind(this)
    })
  },

  handleGetLocationSucc(res) {
    this.setData({
      longitude: res.longitude,
      latitude: res.latitude
    })
  },

  onShareAppMessage(){
    return {
      title: '萌宠交易平台',
      path: '/pages/index/index'
    }
  },

  publishtab(){
    wx.navigateTo({
      url: '/pages/publish/publish',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  },

  searchtab(){
    wx.navigateTo({
      url: '/pages/search/search',
      success: function(res) {},
      fail: function(res) {},
      complete: function(res) {},
    })
  }
})